package com.git_taoxian.test5;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Teat {
    public static void main(String[] args) {
        List<Student> stuList = new ArrayList<>();
        stuList.add(new Student("张三","男","20","88"));
        stuList.add(new Student("李四","女","19","99"));
        stuList.forEach(System.out::println);
        try(//        定义一个缓冲字节输出流对象
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("d:/student.txt"));){

            for (int i = 0; i < stuList.size(); i++) {
                Student stu = stuList.get(i);
                bos.write((stu.toString()+"\r\n").getBytes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
        }
    }
}
